<h1>Checkout</h1>
<? $total = 0; ?>
<? if (count($items)): ?>
	<table class="threew25s comment">
			<tr>
				<th class="w50 left padding10">
					Item
				</th>
				<th style="width: 15%" class="left padding10">
					Quantity
				</th>
				<th style="width: 15%" class="left padding10">
					Price
				</th>
				<th style="width: 20%" class="left padding10">
					Total price
				</th>
			</tr>
		<? foreach ($items as $item): ?>
			<? $total += (round(((float)$item['price'] * (int)$item['quantity']) * 100) / 100) ?>
			<tr>
				<td class="w50 darkBlue padding10">
					<?=Html::anchor(
						Request::$controller . 'deleteItem/' . $item['section'] . '/' . $item['token'] . '/',
						'<img src="/images/icons/small/remove.png" width="12" height="12" alt="Remove form cart"/>'
					)?>
					<?=Html::chars($item['name'])?>
				</td>
				<td style="width: 15%" class="padding10">
					<?=$item['quantity']?>
				</td>
				<td style="width: 15%" class="padding10">
					$<?=$item['price']?>
				</td>
				<td style="width: 20%" class="padding10">
					$<?=(round(((float)$item['price'] * (int)$item['quantity']) * 100) / 100)?>
				</td>
			</tr>
		<? endforeach ?>
		<? if (isset($delivery)): ?>
			<tr>
				<td class="padding10 right" colspan="3">
				<script type="text/javascript">
					function calculateDelivery(el)
					{
						var total = document.getElementById('totalAmount');
						var delivery = document.getElementById('customer-delivery'); if (el.checked) {delivery.value = 1; total.innerHTML = '$<?=$total + $delivery?>';} else {delivery.value = 0; total.innerHTML = '$<?=$total?>';}
					}
				</script>
					Overnight delivery: <input type="checkbox" onclick="calculateDelivery(this)" />
				</td>
				<td style="width: 20%" class="padding10">
					 $<?=$delivery?>
				</td>
			</tr>
		<? endif ?>
		<tr>
			<td class="padding10 bold right" colspan="3">
				Total:
			</td>
			<td style="width: 20%" class="padding10 bold">
				<span id="totalAmount">$<?=$total?></span>
			</td>
		</tr>
	</table>
<? endif ?>
<p>
	<a href="/" class="large darkBlue">&larr; Continue shopping</a>
</p>
<p class="large">Fill up this fields to proceed to the PayPal secure checkout</p>
<? if (isset($form)): ?>
	<?=$form?>
<? endif?>